﻿using System;

namespace CatUtils.Utils.Currency
{
    /// <summary>
    /// 打印日志的方法 写入日志文件的位置为  程序根目录 TempPath\\Log\\
    /// </summary>
    public partial class PrintLog
    {   /// <summary>
        /// 打印不重要日志，打印级别Verbose。灰色。
        /// </summary>
        public static void V(string VerboseLog)
        {
            VerboseLog = "V Log:\r\n" + VerboseLog;
            VNoWrite(VerboseLog);
            WriteLog(VerboseLog);
        }

        /// <summary>
        /// 打印不重要日志，打印级别Verbose。灰色。
        /// </summary>
        /// <param name="Error">需要打印的错误日志</param>
        public static void V(Exception Error)
        {
            V(GetExceptionMessage(Error));
        }

        /// <summary>
        /// 打印不重要日志，打印级别Verbose。灰色。不写入本地记录文件。
        /// </summary>
        public static void VNoWrite(string VerboseLog)
        {
            Console.WriteLine(VerboseLog);
        }

        /// <summary>
        /// 打印不重要日志，打印级别Verbose。灰色。
        /// </summary>
        /// <param name="Error">需要打印的错误日志</param>
        public static void VNoWrite(Exception Error)
        {
            VNoWrite(GetExceptionMessage(Error));
        }

        /// <summary>
        /// 获取错误信息详细日志
        /// </summary>
        /// <param name="Error">出错信息</param>
        /// <returns></returns>
        private static string GetExceptionMessage(Exception Error)
        {
            return Error.ToString();
        }

        /// <summary>
        /// 打印错误日志，打印机别Error。红色。
        /// </summary>
        /// <param name="ErrorLog">需要打印的错误日志</param>
        public static void E(string ErrorLog)
        {
            ErrorLog = "E Log:\r\n" + ErrorLog;
            ENoWrite(ErrorLog);
            WriteLog(ErrorLog);
        }

        /// <summary>
        ///  打印错误日志，打印机别Error。红色。
        /// </summary>
        /// <param name="Error">需要打印的错误日志</param>
        public static void E(Exception Error)
        {
            E(GetExceptionMessage(Error));
        }

        /// <summary>
        /// 打印错误日志，打印机别Error。红色。
        /// </summary>
        /// <param name="ErrorLog">需要打印的错误日志，不写入本地记录文件</param>
        public static void ENoWrite(string ErrorLog)
        {
            ColorLog(ErrorLog, ConsoleColor.Red);
        }

        /// <summary>
        ///  打印错误日志，打印机别Error。红色。
        /// </summary>
        /// <param name="Error">需要打印的错误日志，不写入本地记录文件</param>
        public static void ENoWrite(Exception Error)
        {
            ENoWrite(GetExceptionMessage(Error));
        }

        /// <summary>
        /// 打印调试日志，蓝色。
        /// </summary>
        /// <param name="DebbugLog">需要打印的调试日志</param>
        public static void D(string DebbugLog)
        {
            DebbugLog = "D Log:\r\n" + DebbugLog;
            DNoWrite(DebbugLog);
            WriteLog(DebbugLog);
        }

        /// <summary>
        /// 打印调试日志，蓝色。
        /// </summary>
        /// <param name="Error">需要打印的调试日志</param>
        public static void D(Exception Error)
        {
            D(GetExceptionMessage(Error));
        }

        /// <summary>
        /// 打印调试日志，蓝色。
        /// </summary>
        /// <param name="DebbugLog">需要打印的调试日志，不写入本地记录文件</param>
        public static void DNoWrite(string DebbugLog)
        {
            ColorLog(DebbugLog, ConsoleColor.Blue);
        }

        /// <summary>
        /// 打印调试日志，蓝色。
        /// </summary>
        /// <param name="Error">需要打印的调试日志，不写入本地记录文件</param>
        public static void DNoWrite(Exception Error)
        {
            DNoWrite(GetExceptionMessage(Error));
        }

        /// <summary>
        /// 提示性用户日志。黄色。
        /// </summary>
        /// <param name="InformationLog"></param>
        public static void I(string InformationLog)
        {
            InformationLog = "I Log:\r\n" + InformationLog;
            INoWrite(InformationLog);
            WriteLog(InformationLog);
        }

        /// <summary>
        /// 提示性用户日志。黄色。
        /// </summary>
        /// <param name="Error">需要打印的错误日志</param>
        public static void I(Exception Error)
        {
            I(GetExceptionMessage(Error));
        }

        /// <summary>
        /// 提示性用户日志。黄色。
        /// </summary>
        /// <param name="InformationLog">需要打印的提示日志，不写入本地记录文件</param>
        public static void INoWrite(string InformationLog)
        {
            ColorLog(InformationLog, ConsoleColor.Yellow);
        }

        /// <summary>
        /// 提示性用户日志。黄色。
        /// </summary>
        /// <param name="Error">需要打印的提示日志，不写入本地记录文件</param>
        public static void INoWrite(Exception Error)
        {
            INoWrite(GetExceptionMessage(Error));
        }

        /// <summary>
        /// 打印有颜色的日志
        /// </summary>
        /// <param name="LogText">日志字符串</param>
        /// <param name="color">日志颜色</param>
        public static void ColorLog(string LogText, ConsoleColor color)
        {
            Console.ForegroundColor = color;
            Console.WriteLine(LogText);
            Console.ForegroundColor = ConsoleColor.Gray;
        }
    }
}